<?php
class Application_Form_Metaevento extends ZendX_JQuery_Form
{

    public function init()
    {
        $decorator_hidden_element = array(
            'ViewHelper',
            array(array('data'=>'HtmlTag'), array('tag' => 'td')),
            array(array('row'=>'HtmlTag'),array('tag'=>'tr','style'=>'display:none'))
           );
        
        $decorator_element = array(
            'ViewHelper',
            'Description',
            'Errors',
            array(array('data'=>'HtmlTag'), array('tag' => 'td')),
            array('Label',  array('tag' => 'td', 'style'=>'float:right;')),
            array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
           );
        
        $decorator_submit = array(
           'ViewHelper',
           'Description',
           'Errors', array(array('data'=>'HtmlTag'), array('tag' => 'td',
           'colspan'=>'2','align'=>'center')),
           array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
        );

        $decorator_form = array(
            'FormElements',
            array(array('data'=>'HtmlTag'),array('tag'=>'table')),
            'Form'
        );
  
        $this->setAttrib('accept-charset', 'utf-8')
            ->setName('metaevento');
        
        // campo id
        $id = new Zend_Form_Element_Hidden('id');
        $id->addFilter('Int');
        $id->setDecorators($decorator_hidden_element);
        $this->addElement($id);

        // metaevento
        $metaevento = new Zend_Form_Element_Text('metaevento');
        $metaevento->setLabel('Metaevento')
            ->setAttrib('size', 100)
            ->setRequired(true)
//            ->addFilter('Alnum')
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setDescription('Informe o nome do metaevento')
            ->setDecorators($decorator_element);
        $this->addElement($metaevento);

        // campo mdl_metaevento_id
        $mdl_metaevento_id = new Zend_Form_Element_Text('mdl_metaevento_id');
        $mdl_metaevento_id->setLabel('Moodle ID')
            ->addFilter('Int')
            ->setDescription('Código ID do Metaevento no Moodle')
            ->setDecorators($decorator_element);
        $this->addElement($mdl_metaevento_id);

        // campo responsavel_id
        $usuarios = new Usuarios();
        $responsavel_id = new Zend_Form_Element_Select('responsavel_id');
        $responsavel_id->setLabel('Responsável')
                        ->addMultiOption(null,null);
        $result = $usuarios->fetchAll(null,'nome');
        foreach($result as $responsavel):
            $responsavel_id->addMultiOption($responsavel->id,$responsavel->nome);
        endforeach;
        $responsavel_id->setDecorators($decorator_element);
        $this->addElement($responsavel_id);
        
        // campo status_id
        $status = new Zend_Form_Element_Select('status');
        $status->setLabel('Status');
        $status->addMultiOption('Em produção','Em produção');
        $status->addMultiOption('Disponível','Disponível');
        $status->addMultiOption('Críticas','Críticas');
        $status->setDecorators($decorator_element);
        $this->addElement($status);
        
        //campo obs
        $obs = new Zend_Form_Element_Textarea('obs');
        $obs->setLabel('Obs')
            ->setAttrib('cols', 50)
            ->setAttrib('rows', 11)
            ->setDecorators($decorator_element);
        $this->addElement($obs);

        // botão submit
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setAttrib('id', 'submitbutton')
            ->setDecorators($decorator_submit);
        $this->addElement($submit);
        
        $this->setDecorators($decorator_form);
    }


}

